{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a54c13d8-d3e0-4f90-8574-1cfcfb9ccdee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4×3的整数数组：\n",
      " [[ 1  2  3]\n",
      " [ 4  5  6]\n",
      " [ 7  8  9]\n",
      " [10 11 12]]\n",
      "数组的ndim属性： 2\n",
      "数组的shape属性： (4, 3)\n",
      "数组的size属性： 12\n",
      "数组的dtype属性： int64\n"
     ]
    }
   ],
   "source": [
    "#例2-1参考代码\n",
    "import numpy as np\t\t\t\t\t\t\t#导入NumPy库\n",
    "#创建4×3的整数数组\n",
    "arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])\n",
    "print('4×3的整数数组：\\n', arr)\t\t\t\t#输出数组\n",
    "print('数组的ndim属性：', arr.ndim)\t\t#输出ndim属性\n",
    "print('数组的shape属性：', arr.shape)\t\t#输出shape属性\n",
    "print('数组的size属性：', arr.size)\t\t#输出size属性\n",
    "print('数组的dtype属性：', arr.dtype)\t\t#输出dtype属性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d5ca451b-ac19-449d-aac5-8ce16581488c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "[1 2 3 4 5 6 7 8 9]\n",
      "[1 4 7]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "a=np.array([1,2,3,4,5,6,7,8,9])\n",
    "print(a[2])\n",
    "print(a[:])#a[1]~a[5]不含 从头开始 结尾结束\n",
    "print(a[::3])#起始值 终止值 步长"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fa27e09b-8722-4ca2-864f-605fd0f4b4af",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
